package cc.imos.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * <pre>
 *     Web 配置器
 *
 * Created by asher on 2017/5/22.
 * </pre>
 */
@Configuration
public class BasicWebAdapter extends WebMvcConfigurerAdapter {

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedOrigins("*") // 允许任何域名使用
                .allowedHeaders("*") // 允许任何头
                .allowCredentials(true)
                .allowedMethods("GET", "POST", "DELETE", "PUT") // 允许任何方法（post、get等）
                .maxAge(3600);
    }
}
